package com.yjs.app.trade.service.service.sys.impl;

import java.io.IOException;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yjs.app.trade.core.base.mybatis.dbutil.DynamicSwitchDataSource;
import com.yjs.app.trade.core.util.ClobUtil;
import com.yjs.app.trade.service.mapper.sys.ServiceTermsMapper;
import com.yjs.app.trade.service.service.sys.ServiceTermsService;
/**
 * 服务条款Service
 * @author fgdgf7d4gfd
 *
 */
@Service("serviceTermsService")
@DynamicSwitchDataSource(dataSource = "app")
public class ServiceTermsServiceImpl implements ServiceTermsService {
	@Autowired
	private ServiceTermsMapper serviceTermsMapper;
	
	@Override
	public Map<String, Object> getTOSById(String tosId) throws SQLException, IOException {
		Map<String, Object> map = serviceTermsMapper.getTOSById(tosId);
		Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<String, Object> entry = it.next();
			if (entry.getValue() instanceof Clob) {
				map.put(entry.getKey(), ClobUtil.clobToString((Clob) entry.getValue()));
			}
		}
		return map;
	}

}
